<template>
  <div>
    <van-loading size="24px" vertical>加载中...</van-loading>
  </div>
</template>
<script>
// import { getJwt } from "../../utils/api";
import { Toast } from "vant";
export default {
  name: "author",
  data() {
    return {
      code:'',
      token:''
    };
  },
  created() {
    this.getCode();
  },
  methods: {
    getCode(){
      const code = this.GetUrlParam()//截取路径中code,没有就去授权
      if(code == null|| code === ''){
        location.href ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wwb9164107d1885dd1&agentid=1000399&redirect_uri=http://211.136.107.159:8081/lxm-phone/newWxAuth?callback=http://211.136.107.159:8081/lxm_app/m_index.html&response_type=code&scope=SCOPE&state=STATE&connect_redirect=1#wechat_redirect'
        // location.href ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid +'&redirect_uri='+ local +'&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
      }else{
        console.log('code='+code)
        this.getToken(code)
      }
    },
    getToken(data){
      const param = {
        code:data
      }
      getJwt(param).then(res=>{
        console.log('res='+res)
      })
    },
    GetUrlParam(name){
      console.log('this.$route='+this.$route)
      // var url = location.search
      // this.winUrl = url
      // var theRequest = new Object()
      // if (url.indexOf("?") != -1) {
      //   var str = url.substr(1)
      //   var strs = str.split("&")
      //   for(var i = 0; i < strs.length; i ++) {
      //     theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1])
      //   }
      // }
      //   return theRequest
    }
  },
};
</script>
<style scoped>

</style>
